# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=remot3d
pkgver=38.a707ef7
pkgrel=1
pkgdesc='An Simple Exploit for PHP Language.'
arch=('any')
groups=('blackarch' 'blackarch-webapp' 'blackarch-backdoor'
        'blackarch-exploitation')
url='https://github.com/KeepWannabe/Remot3d'
license=('GPL3')
depends=('bash')
makedepends=('git')
source=("$pkgname::git+https://github.com/KeepWannabe/Remot3d.git"
        "$pkgname.sh.patch")
sha512sums=('SKIP'
            'e04867645a949fc30c6ca8de9422bad2aab779f8064d2255359752d0aaf62bba59ac29e0891857b1f56495e2f595619f71c89b51472d43b19029cc61d710c7c1')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  patch -p1 < "$pkgname.sh.patch"
}

package(){
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname/rmtd-payloads"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bash Remot3d.sh "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

